{% extends "base_generic.html" %}
{% block script %}
<script type="text/javascript">
  function generateUrl(name) {
    var sanitizedName = name;
    sanitizedName = sanitizedName.replace(/ el /gi, ' ');
    sanitizedName = sanitizedName.replace(/ la /gi, ' ');
    sanitizedName = sanitizedName.replace(/ los /gi, ' ');
    sanitizedName = sanitizedName.replace(/ las /gi, ' ');
    sanitizedName = sanitizedName.replace(/ de /gi, ' ');
    sanitizedName = sanitizedName.replace(/ del /gi, ' ');
    sanitizedName = sanitizedName.replace(/ temporada /gi, ' ');
    sanitizedName = string_to_slug(sanitizedName);
    sanitizedName = sanitizedName.replace(/--/gi, '-');
    sanitizedName = sanitizedName.replace(/---/gi, '-');
    sanitizedName = sanitizedName.replace(/----/gi, '-');
    $("#slug").val(sanitizedName);
  }
</script>
{% endblock %}
{% block content %}
        <h1>Project</h1>
        <form action="/admin/projects/{{ project.key }}/save/" method="post">
        <div class="line">
          <div class="field">
            <label>Name:</label>
            <input name="name" type="text" size="30" value="{{ project.name }}" onblur="generateUrl(this.value);"  />
          </div>
          <div class="field">
            <label>URL:</label>
            <input name="url" type="text" size="40" value="{{ project.url }}" />
          </div>
          <div class="field">
            <label>Slug:</label>
            <input name="slug" id="slug" type="text" size="30" value="{{ project.slug }}" />
          </div>
        </div>
        <div class="line">
          <div class="field">
            <label>Server:</label>
            <select name="server">
              {% for server in servers %}
              <option value="{{ server.slug }}"{% ifequal project.server server.slug %} selected="selected"{% endifequal %}>{{ server.name }}</option>
              {% endfor %}
            </select>
         </div>
         <div class="field">
           <label>Language:</label>
           <select name="lang">
             <option value="es"{% ifequal project.lang 'es' %} selected="selected"{% endifequal %}>Spanish</option>
             <option value="en"{% ifequal project.lang 'en' %} selected="selected"{% endifequal %}>English</option>
             <option value="de"{% ifequal project.lang 'de' %} selected="selected"{% endifequal %}>German</option>
             <option value="pt"{% ifequal project.lang 'pt' %} selected="selected"{% endifequal %}>Portuguese</option>
             <option value="fr"{% ifequal project.lang 'fr' %} selected="selected"{% endifequal %}>French</option>
             <option value="it"{% ifequal project.lang 'it' %} selected="selected"{% endifequal %}>Italian</option>
           </select>
        </div>
        <div class="field">
           <label>Status:</label>
           <select name="status">
             <option></option>
             <option value="justlaunched"{% ifequal project.lang 'justlaunched' %} selected="selected"{% endifequal %}>Just launched</option>
             <option value="running"{% ifequal project.lang 'running' %} selected="selected"{% endifequal %}>Running</option>
             <option value="onhold"{% ifequal project.lang 'onhold"' %} selected="selected"{% endifequal %}>On hold</option>
           </select>
        </div>
        <div class="field">
           <label>Type:</label>
           <select name="type">
             <option value="autoblog"{% ifequal project.lang 'autoblog' %} selected="selected"{% endifequal %}>autoblog</option>
             <option value="blog"{% ifequal project.lang 'blog' %} selected="selected"{% endifequal %}>blog</option>
             <option value="tumblr"{% ifequal project.lang 'tumblr' %} selected="selected"{% endifequal %}>tumblr</option>
             <option value="directory"{% ifequal project.lang 'directory' %} selected="selected"{% endifequal %}>directory</option>
             <option value="corporate"{% ifequal project.lang 'corporate' %} selected="selected"{% endifequal %}>corporate</option>
           </select>
        </div>
       </div>
       <div class="line">
         <div class="field">
           <label>Favicon:</label>
           <input name="favicon" type="text" size="50" value="{% if project.favicon %}{{ project.favicon }}{% else %}{{ project.url }}/favicon.ico{% endif %}" /> <img src="{{ project.url }}/favicon.ico" />
         </div>
       </div>
        <input type="submit" value="Guardar" id="save" name="save" name="save" /><br class="clear" />
      </form>
      <br class="clear" />

{% endblock %}
      